#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >ans;
void solve(int x1,int y1,int x2,int y2)
{
	int n=x2-x1+1,m=y2-y1+1;
	if(n<m)
	{
		for(int i=x1;i<=x2;i++)
			ans.push_back({i,y1});
		solve(x1,y1+n,x2,y2);
	}
	else if(n>m)
	{
		for(int i=y1;i<=y2;i++)
			ans.push_back({x2,i});
		solve(x1,y1,x2-m,y2);
	}
	else
	{
		for(int i=y1;i<=y2;i++)
			ans.push_back({x1,i});
		for(int i=y1+1;i<y2;i++)
			ans.push_back({x2,i}); 
	}
}
int main()
{
	freopen("bishop.in","r",stdin);
	freopen("bishop.out","w",stdout);
	int n,m;
	scanf("%d%d",&n,&m);
	solve(1,1,n,m);
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++)
		printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}
